package com.ikas.ai.server.module.analyse.model.vo;

import lombok.Builder;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * 3sigma
 *
 * @author tang.xuandong
 * @version 1.0.0
 * @date 2023/5/4 16:04
 */
@Data
public class ThreeSigmaVo {

    // 平均值
    private Double avg;

    // 标准差
    private Double standardDeviation;

    // +3σ
    private Double pThreeSigma;

    // +2σ
    private Double pTwoSigma;

    // +1σ
    private Double pOneSigma;

    // -1σ
    private Double nOneSigma;

    // -2σ
    private Double nTwoSigma;

    // -3σ
    private Double nThreeSigma;

    // 上限
    private Double upperLimit;

    // 下限
    private Double lowerLimit;

    public ThreeSigmaVo(){
    }

    public static ThreeSigmaVo build(ThreeSigmaVo v){
        ThreeSigmaVo vo = new ThreeSigmaVo();
        vo.setAvg(BigDecimal.valueOf(v.getAvg()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        vo.setStandardDeviation(BigDecimal.valueOf(v.getStandardDeviation()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        vo.setPThreeSigma(BigDecimal.valueOf(v.getPThreeSigma()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        vo.setPTwoSigma(BigDecimal.valueOf(v.getPTwoSigma()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        vo.setPOneSigma(BigDecimal.valueOf(v.getPOneSigma()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        vo.setNOneSigma(BigDecimal.valueOf(v.getNOneSigma()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        vo.setNTwoSigma(BigDecimal.valueOf(v.getNTwoSigma()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        vo.setNThreeSigma(BigDecimal.valueOf(v.getNThreeSigma()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        vo.setUpperLimit(BigDecimal.valueOf(v.getUpperLimit()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        vo.setLowerLimit(BigDecimal.valueOf(v.getLowerLimit()).setScale(3, RoundingMode.HALF_UP).doubleValue());
        return vo;
    }

}
